package UIUtils
{
	public class uif_utilS extends Object {
		public static function checkEMail(email: String): Boolean {
			var chars: Array = email.match("^[a-zA-Z0-9\-\._]+@[-a-zA-Z0-9\-]+\.[-a-zA-Z0-9\-\.]+$");
			return (chars) && (chars.length == 1);
		}
				
		public static function translit(s:String):String { /* массив, хранящий правила транслитерации */ 
			var arr:Array = new Array(["А","A"],["Б","B"],["В","V"],["Г","G"],["Д","D"],["Е","E"],["Ё","E"],["Ж","J"],["З","Z"],["И","I"],["Й","Y"],["К","K"],["Л","L"],["М","M"],["Н","N"],["О","O"],["П","P"],["Р","R"],["С","S"],["Т","T"],["У","U"],["Ф","F"],["Х","H"],["Ц","Ts"],["Ч","Ch"],["Ш","Sh"],["Щ","Sch"],["Ъ",""],["Ы","Yi"],["Ь",""],["Э","E"],["Ю","Yu"],["Я","Ya"],["а","a"],["б","b"],["в","v"],["г","g"],["д","d"],["е","e"],["ё","e"],["ж","j"],["з","z"],["и","i"],["й","y"],["к","k"],["л","l"],["м","m"],["н","n"],["о","o"],["п","p"],["р","r"],["с","s"],["т","t"],["у","u"],["ф","f"],["х","h"],["ц","ts"],["ч","ch"],["ш","sh"],["щ","sch"],["ъ","y"],["ы","yi"],["ь",""],["э","e"],["ю","yu"],["я","ya"]); 
			/* результирующая строка */ 
			var r:String = ""; 
			/* текущая буква */ 
			var b:String = ""; 
			/* длина строки, к которой будет применена транслитерация */ 
			var lenS:uint = s.length; 
			/* длина массива с правилами транслитерации */ 
			var lenA:uint = arr.length; /* циклы, которые и выполняют перевод строки в транслит */ 
			var i:uint = 0; 
			var j:uint;
			while (i < lenS) { b = s.substr(i,1); j = 0; 
				while (j < lenA) { if (b == arr[j][0]) { b = arr[j][1]; } j++; } r += b; i++;} /* возвращаем результат */ 
			return r; 
		}		
	}
}